package com.zhongke.cotrun.mapper;

import com.zhongke.cotrun.model.pojo.LevelTwoComment;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface LevelTwoCommentMapper {
    /**
     * 新增二级评论
     *
     * @param levelTwoComment
     * @return
     */
    @Options(useGeneratedKeys = true, keyProperty = "levelTwoCommentId", keyColumn = "level_two_comment_id")
    @Insert("INSERT INTO `level_two_comment` (`link_comment_id`, `link_user_id`,`my_name`,`my_head`, `who_comment_id`,`his_name`, `create_time`, `comment_content`,`state`,`type`) VALUES (#{linkCommentId}, #{linkUserId},#{myName},#{myHead}, #{whoCommentId},#{hisName},NOW(), #{ commentContent},0,#{type})")
    public Boolean insertLevelTwoComment(LevelTwoComment levelTwoComment);

    /**
     * 修改二级评论状态
     *
     * @param state
     * @param levelOneCommentId
     * @return
     */
    @Update("UPDATE `level_two_comment` SET `state`=#{state} WHERE (`level_two_comment_id`=#{levelOneCommentId})")
    public Boolean updateStateForLevelTwoComment(@Param("state") Integer state, @Param("levelOneCommentId") Integer levelOneCommentId);

    /**
     * 查看二级评论
     *
     * @return
     */
    public List<LevelTwoComment> selectLevelTwoComment(LevelTwoComment levelTwoComment);

    /**
     * 查看二级评论的相关人
     * @param id
     * @return
     */
    @Select("SELECT link_user_id FROM level_two_comment WHERE level_two_comment_id=#{id}")
    public Integer selectLevelTwoCommentLinkUserById(Integer id);

}
